<?php
if (isset($_POST['acceptShiftChange'])) {
    AcceptShiftChange($_SESSION['userName'], $_SESSION['userPassHash'], $_POST['empID'], $_POST['roleID'], $_POST['dateID'], $_POST['myEmpID']);
} elseif (isset($_POST['rejectShiftChange'])) {
    RemoveShiftChange($_SESSION['userName'], $_SESSION['userPassHash'], $_POST['empID'], $_POST['roleID'], $_POST['dateID']);
}
?><h3>Requests Manager</h3><?php
$shiftChanges = ViewProposedChange($_SESSION['userName'], $_SESSION['userPassHash']);
if (count($shiftChanges) > 1) {
    ?>
    <table class="table table-striped">
        <thead>
            <tr>
                <th>Seller</th>
                <th>Buyer</th>
                <th>Role</th>
                <th>Date</th>
                <th>Approve/Reject</th>
            </tr>
        </thead>
        <tbody>
            <?php
            for ($i = 1; $i < count($shiftChanges); $i++) {
                ?><tr>
                    <td><?php echo($shiftChanges[$i]['empFname'] . " " . $shiftChanges[$i]['empLname'] ); ?></td>
                    <td><?php echo($shiftChanges[$i]['myEmpFname'] . " " . $shiftChanges[$i]['myEmpLname'] ); ?></td>
                    <td><?php echo($shiftChanges[$i]['roleName']); ?></td>
                    <td><?php echo($shiftChanges[$i]['dateStamp']); ?><br />
                        <?php echo($shiftChanges[$i]['startTime']); ?> - 
                        <?php echo($shiftChanges[$i]['endTime']); ?></td>
                    <td>
                        <form action="" method="post">
                            <input type="hidden" name="empID" value="<?php echo($shiftChanges[$i]["empID"]); ?>" />
                            <input type="hidden" name="myEmpID" value="<?php echo($shiftChanges[$i]["myEmpID"]); ?>"/>
                            <input type="hidden" name="roleID" value="<?php echo($shiftChanges[$i]["roleID"]); ?>"/>
                            <input type="hidden" name="dateID" value="<?php echo($shiftChanges[$i]["dateID"]); ?>"/>
                            <input type="submit" name="acceptShiftChange" value="Accept" class="btn btn-primary" />
                            <input type="submit" name="rejectShiftChange" value="Reject" class="btn btn-danger" />
                        </form>
                    </td>
                </tr>
                <tr></tr><?php
            }
            ?>
        </tbody>
    </table>
<?php } ?>